<template>
	<view>

		<!--返回-->
		<view class="jiangqie-back-btn" @click="jumpBtn">
			<image src="@/static/images/new/back.png" mode="widthFix"></image>
		</view>
		<view class="container jiangqie-page-view" v-if="detailsObj.classType == 1">
			<image class="image-self" style="height: 100vh;width: 100vw;display: flex;" mode="aspectFill" :src="detailsObj.image"></image>
		</view>
		<view class="container jiangqie-page-view" v-if="detailsObj.classType == 2">
			<video class="image-self" style="height: 100vh;width: 100vw;display: flex;" mode="aspectFill" :src="detailsObj.image" :autoplay="true"></video>
		</view>
		<view class="container jiangqie-page-view" v-if="detailsObj.classType == 3">
			<image class="background-image" mode="aspectFill" :src="detailsObj.image"></image>
		</view>
		<view class="container jiangqie-page-view" v-if="detailsObj.classType == 4">
			<image class="emoticon" mode=""   :src="detailsObj.image" ></image>
		</view>
		<view class="container jiangqie-page-view" v-if="detailsObj.classType == 5">
			<image class="emoticon" mode="" :src="detailsObj.image"></image>
		</view>

		<!--用户头像-->
		<view class="jiangqie-user-btn" v-if="talent" :data-userid="talent.userid" @click.stop.prevent="talentClick">
			<image :src="talent.pic" mode="widthFix" style="max-height: 48px;border-radius: 50rpx;"></image>
		</view>

		<view class="jiangqie-nickname-btn" v-if="talent">
			<text>{{ talent.word }}</text>
		</view>

		<view class="jiangqie-down-btn" @click.stop.prevent="downloadShow" v-if="post.switch_comment == 1">
			<image src="@/static/images/new/down.png" mode="widthFix"></image>
		</view>
		<!--点赞-->
		<view class="jiangqie-like-btn" @click.stop.prevent="handlerLikeClick">
			<block v-if="post_like == 1">
				<image src="@/static/images/new/like-yes.png" mode="widthFix"></image>
			</block>
			<block v-else>
				<image src="@/static/images/new/like-no.png" mode="widthFix"></image>
			</block>
		</view>

		<!--收藏-->
		<view class="jiangqie-coll-btn" @click.stop.prevent="handlerFavoriteClick" :data-like="post_favorite == 1">
			<block v-if="post_favorite == 1">
				<image src="@/static/images/new/coll-yes.png" mode="widthFix"></image>
			</block>
			<block v-else>
				<image src="@/static/images/new/coll-no.png" mode="widthFix"></image>
			</block>
		</view>



		<!--加载框 start-->
		<tui-loading :visible="loading"></tui-loading>
		<!--加载框 end  modelShow  @click.stop.prevent="clickMask"-->

		<view class="mask" v-if="modelShow">
			<view class="modal-content" :style="'height:' + height">
				<text class="cuIcon-close text-gray"
				  style="float: right;font-size: 50rpx;padding: 5px;" @click.stop.prevent="clickMask"></text>
				<view class="huoqu">素材下载</view>

				<view class="jifen text-center cu-btn bg-blue round down-btn"
				 @click.stop.prevent="downFile" data-clickbtn="1" v-if="detailsObj.classType == 2">
						<text class="cuIcon-video cuIconfont-spin" >  </text>
						超清下载
				</view>
				<view class="jifen text-center cu-btn bg-blue round down-btn"
				 @click.stop.prevent="downFile" data-clickbtn="1" v-else>
						原图下载
				</view>
				<view class="shiping">超清无水印{{detailsObj.classType == 2 ? '视频' : '原图'}}</view>
				<view class="shiping2">看完广告，即可获取</view>

				<view style="margin-top: 30px;">

				</view>

				<view class="jifen text-center cu-btn bg-blue round down-btn"
				 @click.stop.prevent="downFile" data-clickbtn="0" v-if="detailsObj.originalVideo">
						<text class="cuIcon-video cuIconfont-spin" > </text>
						视频下载
				</view>
				<view class="shiping" v-if="detailsObj.originalVideo">无水印原视频</view>
				<view class="shiping2" v-if="detailsObj.originalVideo">看完广告，即可获取</view>

				<view style="margin-top: 30px;" v-if="detailsObj.originalVideo">
				</view>

				<view v-if="putongDown == 1">
					<view class="jifen text-center cu-btn bg-grey round down-btn-noad"
					@click.stop.prevent="downFilePutong" data-clickbtn="2">
							普通下载
					</view>
					<view class="putong">普通画质</view>
					<view class="putong-tishi">无需广告，即可下载</view>
				</view>

				<view class="tishi-ad">
					<view class="tishi-ad">每天看{{adCount}}次广告，可免费下载{{downCount}}次原图</view>
				</view>
				<!--
				<view class="guoshao-shipin">
					<image src="@/static/images/new/shipin.png" mode="widthFix" class="shipinLogo" />
					<view style="margin-right: 20px" @click="seeShipin">观看视频获取9积分</view>
				</view>
				-->
			</view>
		</view>
	</view>
</template>

<script>
	import tuiLoading from "../../components/loading/loading";
	import tuiLoadmore from "../../components/loadmore/loadmore";
	import tuiNomore from "../../components/nomore/nomore";

	/*
	 * Author: 郭少
	 * github: https://github.com/guoshao99/wallpaper-applet
	 * gitee: https://gitee.com/guoshao99/wallpaper-applet
	 * QQ：2549789059
	 * 微信：2549789059
	 */

	const Authentication = require('../../utils/authentication.js');

	const Constants = require('../../utils/constants');

	const Util = require('../../utils/util');

	const Api = require('../../utils/api.js');

	const Rest = require('../../utils/rest');

	const storage = require('../../utils/storage.js');

	let rewardedVideoAd = null;

	let setinad = null;

	const http = require('../../utils/http.js');

	const util = require('../../utils/util.js');

	const platformEnv = require('../../utils/platformEnv.js');

	export default {
		components: {
			tuiLoading,
			tuiLoadmore,
			tuiNomore
		},
		data() {
			return {
				loginReq:false,
				post: {
					switch_comment: 0
				},

				detailsObj: {
					classType: 0,
					thumbnail: ""
				},

				post_like: 0,
				post_favorite: 0,
				loadding: false,
				pullUpOn: true,
				loaded: false,
				pagead: 7,
				integra: 0,
				modelShow: false,

				talent: {
					word: ""
				},

				modalName: {},
				detailSummaryHeight: {},
				loading: false,
				height: "",

				userId: Authentication.getUserId(),
				post_id: 0,
				comment_id: 0,
				flag: 1,
				adCount : 3,  //广告观看次数
				downCount:5,  //下载次数
				imageWidth:0,
				imageHeight:0,
				clickbtn: -1  ,//点击的按钮  1原图下载 2普通下载
				putongDown:2,
				myData:false,
				closeProfit:0
			};
		},
		onUnload() {

			uni.hideLoading();
		},
		onLoad: function(options) {
			this.onLoadClone3389(options);
			this.flag = options.flag;
			this.myData = options.myData;
			let that = this;

			Util.getAD(that, function() {
				//that.setInterstitialAd(); //加载插屏广告
				//加载激励视频广告
				that.loadInterstitialAd();
			});

			var params = {
				url: "/platform/data.json",
				method: "GET",
				data: {
					'id': that.post_id,
					userId:Authentication.getUserId()
				},
				callBack: function(res) {
					that.setData({
						detailsObj: res.data.bzWallpaper,
						post: res.data,
						post_favorite: res.data.post_favorite ? res.data.post_favorite : 0,
						post_like: res.data.post_like ? res.data.post_like : 0,
						talent: res.data.talent,
						adCount:res.data.adCount,
						downCount:res.data.downCount,
						showAd:res.data.showAd,
						putongDown:res.data.putongDown,
						closeProfit:res.data.closeProfit
					});

					if(that.detailsObj.classType == 4 || that.detailsObj.classType == 5){
						uni.getImageInfo({
							src:that.detailsObj.thumbnail,
							success (res) {
								that.setData({
									imageWidth : res.width+"px",
									imageHeight: res.height+"px"
								});
							}
						})
					}

				}
			};
			http.request(params);

		},
		onShow: function() {


		},
		onHide() {
			clearInterval(setinad);
		},
		onReachBottom: function() {
			if (!this.pullUpOn) {
				return;
			}

		},
		onShareAppMessage: function() {
			let that = this;
			let shaData = that.shares;
			let share_title =  '免费下载高清壁纸,头像,表情包';

			if (null != shaData) {
				share_title = shaData.share_title;
			}

			uni.showShareMenu({
				withShareTicket: true,
				menus: ['shareAppMessage', 'shareTimeline']
			});
			return {
				title: share_title,
				imageUrl: this.detailsObj.thumbnail,
				path: 'pages/article/article?post_id=' + this.post_id
			};
		},
		onShareTimeline: function() {
			let that = this;
			let shaData = that.shares;
			let share_title = "【" + that.post.title + "】分享这张好看的壁纸给你~";

			if (null != shaData) {
				share_title = shaData.share_title;
			}

			return {
				title: share_title,
				query: 'post_id=' + that.post_id,
				imageUrl: that.detailsObj.thumbnail
			};
		},

		methods: {
			onLoadClone3389: function(options) {
				if (options.scene) {
					this.post_id = decodeURIComponent(options.scene);
				} else {
					if (options.post_id) {
						this.post_id = options.post_id;
					}
				}
			},

			// 获取小程序插屏广告
			setInterstitialAd: function() {
				var that = this;

				if (that.setAD.interstitialid && uni.createInterstitialAd) {
					let interstitialAd = uni.createInterstitialAd({
						adUnitId: that.setAD.interstitialid
					}); // 监听插屏错误事件

					interstitialAd.onError(err => {
						console.error(err);
					}); // 显示广告

					if (interstitialAd) {
						if (that.setAD.switch_inad == 'yes') {
							setinad = setInterval(() => {
								interstitialAd.show().catch(err => {
									console.error(err);
								});
							}, 2000);
						} else {
							setTimeout(() => {
								interstitialAd.show().catch(err => {
									console.error(err);
								});
							}, 6000);
						}
					}
				}
			},

			/**
			 * 跳转返回
			 */
			jumpBtn: function(options) {
				uni.hideLoading();
				let that = this;
				if (that.flag == 1) {
					uni.switchTab({
						url: '/pages/index/index'
					});
				} else {
					Util.navigateBack();
				}
			},

			/**
			 *  点赞
			 */
			handlerLikeClick: function(e) {
				var that = this;
				if (Authentication.getUserId() == '') {
					if(!that.loginReq){
						that.loginReq = true;
						http.getUserProfile(function(){
							that.setData({
								userId: Authentication.getUserId()
							})
							that.updateCount(that.post_id, 2);
						},that);
					}
				}else{
					that.updateCount(that.post_id, 2);
				}

			},



			/**
			 * 收藏
			 */
			handlerFavoriteClick: function(e) {
				var that = this;
				if (Authentication.getUserId() == '') {
					if(!that.loginReq){
						that.loginReq = true;
						http.getUserProfile(function(){
							that.setData({
								userId: Authentication.getUserId()
							})
							that.updateCount(that.post_id, 1);
						},that);
					}
				}else{
					that.updateCount(that.post_id, 1);
				}

			},


			showModal(e) {
				this.setData({
					modalName: e.currentTarget.dataset.target
				});
			},

			hideModal(e) {
				this.setData({
					modalName: null
				});
			},

			getUserProFile:function(){
				let that = this;
				if(!that.loginReq){
					that.loginReq = true;
					http.getUserProfile(function(){
						that.setData({
							modelShow : true,
							userId: Authentication.getUserId()
						})
					},that);
				}
			},
			/**
			 * @param {Object} e
			 * 显示模态框
			 */
			downloadShow: function(e) {
				var that = this;
				if (Authentication.getUserId() == '') {
					that.getUserProFile();
				}else{
					this.setData({
						modelShow : true
					})
				}

			},
			/**
			 * 下载文件
			 */
			downFile:function(e){

				this.clickbtn = e.currentTarget.dataset.clickbtn;
				console.log("==========:"+this.clickbtn);
				let self = this;

				let adCount = this.adCount; //每日广告次数
				let dCount = this.downCount; //每日下载次数
				//判断单日下载次数
				var openAdLogs = uni.getStorageSync('openAdLogs');

				//var openAdLogs = [];
				var atdate = new Date();
				atdate = atdate.getFullYear() + "-" + (atdate.getMonth() + 1) + '-' + atdate.getDate();

				if (undefined == openAdLogs || openAdLogs.length <= 0) { //缓存不存在
					if(self.showAd == 1){
					  self.readMore();
					}else{
					  self.downloadMyFile();
					}
				}else{

					//缓存存在
					if (openAdLogs[0].date == atdate) {

						//下载数量小于设置数量
						if(parseInt(openAdLogs[0].downCount) < dCount){
							//验证观看广告次数  观看次数小于设置次数
							if(parseInt(openAdLogs[0].num) < adCount){
								//显示广告
								if(self.showAd == 1){
								  self.readMore();
								}else{
								  self.downloadMyFile();
								}
							}else{
								//直接下载
								self.downloadMyFile();
							}
						}else{
							//可能存在 广告次数大于下载数
							if(parseInt(openAdLogs[0].num) < adCount){
								//显示广告
								if(self.showAd == 1){
								  self.readMore();
								}else{
								  self.downloadMyFile();
								}
							}else{
								self.setData({
									modelShow:false
								})
								uni.showToast({
									title:'已经下载'+dCount+'张啦,等明天再来下载吧!',
									icon:'none'
								})
							}
						}
					}else{
						//缓存存在，并非同一天
						if(self.showAd == 1){
						  self.readMore();
						}else{
						  self.downloadMyFile();
						}
					}

				}

			},

			hideMyModel:function(){
				this.setData({
					modelShow:false
				})
			},
			/**
			 * 下载文件
			 */
			downloadMyFile: function() {
				let that = this;
				if (that.detailsObj.classType == 2) {
					that.handleDownloadVideo();
				} else if(that.clickbtn == 0){
					that.handleDownloadVideo();
				}else{
					that.downloadPhoto();
				}
			},

		saveImage:function(filePath){
			let that = this;
			uni.saveImageToPhotosAlbum({
				filePath: filePath,
				success: function(data) {
					//执行设置缓存方法
					that.setDownCache();
					that.hideMyModel();
					uni.showToast({
						title: '保存成功',
						icon: "success",
						duration: 2000,
						success() {

						}
					});
				}
			});
		},

		//下载壁纸
		downloadPhoto: function(e) {
			var that = this;

			var photourl = that.detailsObj.image;

			if(that.clickbtn == 2){
				photourl = that.detailsObj.lowImageQuality;
			}
			if(photourl == '' || photourl == undefined || photourl == null){
				that.addLogo("图片地址为空","图片地址为空");
				uni.hideLoading();
				uni.showModal({
					title:'提示',
					content:'图片下载失败，请联系平台管理员'
				})
				return;
			}

			// 获取图片信息
			// var extension = photourl.substring(photourl.lastIndexOf('.') + 1);
			//let fileName = new Date().valueOf();

			uni.downloadFile({
				url: photourl,
				//filePath: uni.env.USER_DATA_PATH + '/' + fileName + '.jpg',
				success: function(downSucc) {
					let filePath = downSucc.tempFilePath;
					console.log(downSucc);
					console.log("下载成功");
					uni.showLoading({
						title: '保存中',
						duration: 3000
					});
					//延迟执行保存
					setTimeout(function(){
						uni.saveImageToPhotosAlbum({
							filePath: filePath,
							success: function(succ) {
								console.log(succ);
								console.log("保存成功")
								//执行设置缓存方法
								that.setDownCache();
								that.hideMyModel();
								uni.hideLoading();
								uni.showToast({
									title: '保存成功',
									icon: "success",
									duration: 2000,
									success() {
									}
								});
							},
							fail: function(derr) {
								uni.hideLoading();
								if ("saveImageToPhotosAlbum:fail cancel" === derr.errMsg) {
									uni.hideLoading();
									return;
								}

								console.log(derr);
								console.log("保存失败");
								that.addLogo(JSON.stringify(derr),"图片保存时失败-1");
								//writePhotosAlbum
								//if("saveImageToPhotosAlbum:fail auth deny" === derr.errMsg){
								if(derr.errMsg){
									console.log("保存失败，进入授权了");
									uni.openSetting({
										success: function (res) {
											console.log("保存失败，进入授权了-2");
										  uni.authorize({
											scope: 'scope.writePhotosAlbum',
											success(settingdata) {
											  //用户打开了保存图片授权开关
											  that.saveImage(filePath);
											  console.log("进入授权了-3");
											},
											fail(error) {
												console.log(error);
												console.log("拒绝授权");
												that.addLogo(JSON.stringify(error),"拒绝授权时，则进入手机设置页面3");
												  uni.openSetting({
													success: function (data) {
													  //用户打开了保存图片授权开关
													  that.saveImage(filePath);
													},
													fail: function (data) {
														that.addLogo(JSON.stringify(openErr),"打开授权页面失败-2");
													}
												  });
											}

										  });
										  },
										  fail: (openErr) => {
											  that.addLogo(JSON.stringify(openErr),"打开授权页面失败");
										  },
									});
								}
								uni.hideLoading();
							},
							complete: function(dc) {
							}
						});
					},400)
					//延迟
				},
				fail: function(data) {
					uni.hideLoading();
					uni.showModal({
						title:'提示',
						content:'图片下载失败，请联系平台管理员'
					})
					that.addLogo(JSON.stringify(data),"图片下载失败-1");
				}
			});
		},

		/**
		 * @param {Object} e 下载图片
		 */
		downFilePutong:function(e){
			this.clickbtn = e.currentTarget.dataset.clickbtn;
			this.downloadPhoto();
		},

		// 打开激励视频
		readMore: function() {
			if (rewardedVideoAd) {
				rewardedVideoAd.show().catch(err => {
					// 失败重试
					rewardedVideoAd.load().then(() => rewardedVideoAd.show())
				})
			}
		},

		//加载广告
		loadInterstitialAd: function() {
			var that = this;
			var adCount = this.adCount;

			if (uni.createRewardedVideoAd) {

				if(platformEnv.SystemType == 4 || platformEnv.SystemType == 1){
					rewardedVideoAd = uni.createRewardedVideoAd({
						adUnitId: that.setAD.rewardedVideoid,
					});
				}else if(platformEnv.SystemType == 5){
					rewardedVideoAd = ks.createRewardedVideoAd({
					   type: that.setAD.adType,
					   unitId: that.setAD.rewardedVideoid,
				    });
				}

				  try{
					  if(rewardedVideoAd.closeHandler){
						rewardedVideoAd.offClose(rewardedVideoAd.closeHandler);
						console.log("rewardedVideoAd.offClose卸载成功");
					  }
				  } catch (e) {
					  console.log("rewardedVideoAd.offClose 卸载失败");
					  console.error(e);
				  }
				  rewardedVideoAd.closeHandler= function (res) {
					  // 正常播放结束，可以下发游戏奖励
					  // 用户点击了【关闭广告】按钮
					  if (res && res.isEnded) {
						// 正常播放结束，可以下发游戏奖励
						console.log("播放完毕   1");

						that.downloadMyFile();
						that.saveBalance();

					  } else {
						//提前关闭小程序
						 console.log("播放完毕   未完成");
					  }

				  };
				  rewardedVideoAd.onClose(rewardedVideoAd.closeHandler);

				  rewardedVideoAd.onError(err => {
					console.log(err)
				  })
				}
			},

			saveVideo:function(filePath){
				let that = this;
				uni.saveVideoToPhotosAlbum({
					filePath: filePath,
					success: function(data) {
						//执行设置缓存方法
						that.setDownCache();
						that.hideMyModel();
						uni.showToast({
							title: '保存成功',
							icon: "success",
							duration: 3000,
							success() {

							}
						});
					}
				});
			},
			//下载 视频
			handleDownloadVideo(e) {
				let that = this; //下载地址

				let link = this.detailsObj.image;
				if(that.clickbtn == 0){
					link = this.detailsObj.originalVideo;
				}
				console.log(this.clickbtn);

				uni.showLoading({
					title: '正在保存',
					duration: 4000
				});
				uni.downloadFile({
					url: link,
					success: res => {
						let filePath = res.tempFilePath;
						uni.saveVideoToPhotosAlbum({
							filePath:filePath,
							success: file => {
								//执行设置缓存方法
								that.setDownCache();
								that.hideMyModel();
								uni.showToast({
									title: '下载成功',
									icon: "success",
									duration: 3000,
									success() {

									}
								});
							},
							fail: err => {

								//取消下载
								if ("saveVideoToPhotosAlbum:fail cancel" === err.errMsg) {
									uni.hideLoading();
									return;
								}

								that.addLogo(JSON.stringify(err),"下载文件授权-视频-1");

								"saveVideoToPhotosAlbum:fail auth deny" === err.errMsg && uni.openSetting({

									success: function (sres) {
										if (!sres.authSetting['scope.writePhotosAlbum']  || !res.authSetting['scope.album']) {
										  uni.authorize({
											scope: 'scope.album',
											success(settingdata) {
											  //用户打开了保存图片授权开关
											  that.saveVideo(filePath);
											},
											// // 拒绝授权时，则进入手机设置页面，可进行授权设置
											fail(error) {
											  uni.openSetting({
												success: function (data) {
												  //用户打开了保存图片授权开关
												  that.saveVideo(filePath);
												},
												fail: function (data) {
												}
											  });
											}

										  });
										} else {
										  // 已授权则直接进行保存图片
										  //用户打开了保存图片授权开关
										  that.saveVideo(filePath);
										}
									}
								})

							},
							complete: function(dc) {
							}
						});
					}
				});
			},

			//设置缓存  下载缓存
			setDownCache:function(){
				//不是看广告
				if(this.clickbtn == 2){
					console.log("不是看广告的");
					return;
				}
				console.log("原图下载");
				var that = this;

				let adCount = that.adCount;

				var nowDate = new Date();
				nowDate = nowDate.getFullYear() + "-" + (nowDate.getMonth() + 1) + '-' + nowDate.getDate();
				var openAdLogs = [];

				let adLogs = uni.getStorageSync("openAdLogs");

				if(undefined == adLogs || adLogs.length <= 0){
					//缓存不存在
					var log = {
						"id": that.detailsObj.id,
						"date": nowDate,
						"num": 1,
						"downCount":1
					}
					openAdLogs[0] = log;
					uni.setStorageSync('openAdLogs', openAdLogs);
				}else{
					//同一天相加
					if (adLogs[0].date == nowDate) {
						//如果已经看完不在累加
						let num = adLogs[0].num >= adCount ? adLogs[0].num : adLogs[0].num + 1;
						let dCount = adLogs[0].downCount + 1;
						var log = {
							"id": that.detailsObj.id,
							"date": nowDate,
							"num": num,
							"downCount":dCount
						}
						openAdLogs[0] = log;
						uni.setStorageSync('openAdLogs', openAdLogs);
					}else{
						//缓存存在，不是同一天，数量从1开始
						var log = {
							"id": that.detailsObj.id,
							"date": nowDate,
							"num": 1,
							"downCount": 1
						}
						openAdLogs[0] = log;
						uni.setStorageSync('openAdLogs', openAdLogs);
					}
				}
			},

			//修改浏览数数量
			updateCount: function(id, type) {
				//flag =1收藏2点赞3浏览

				if (Authentication.getUserId() == '') {
					uni.showModal({
						title: '提示',
						content: '请登录后在操作',
						success(res) {
							if (res.confirm) {
								uni.switchTab({
									url:'/pages/ucenter/ucenter'
								})
							}
						}
					});
					return;
				}

				let that = this;

				var params = {
					url: "/p/favorite/saveOrUpdate",
					method: "POST",
					dataType: "json",
					data: {
						wallpaperId: id,
						type: type
					},
					callBack: function(res) {
						if (res.code == 200) {
							that.setData({
								post_favorite: res.data.post_favorite,
								post_like: res.data.post_like
							});
							if(that.myData == true || that.myData == 'true'){
								setTimeout(function(){
									let pages = getCurrentPages(); // 获取所有页面栈实例列表
									let beforePage = pages[pages.length - 2]; // 上一页
									beforePage.$vm.loadPost(true);
								},500);
							}

						}
					}
				};


				http.request(params);

			},

			//获取上一条下一条数据
			upAndDownData: function(flag) {
				let that = this;
				let userId = this.userId;
				var params = {
					url: "/platform/upAndDownData",
					method: "GET",
					dataType: "json",
					data: {
						id: that.detailsObj.id,
						flag: flag,
						openid: userId
					},
					callBack: function(res) {
						if (res.code != 200) {
							uni.showToast({
								title: res.msg,
								icon: 'none'
							});
							return;
						}

						if (res.data == null) {
							return;
						}

						that.post_id = res.data.bzWallpaper.id;
						that.setData({
							detailsObj: res.data.bzWallpaper,
							post: res.data,
							post_favorite: res.data.post_favorite ? res.data.post_favorite : 0,
							post_like: res.data.post_like ? res.data.post_like : 0
						});
					}
				};
				http.request(params);
			},



			/**
			 * 保存余额
			 */
			saveBalance: function() {
				let that = this;
				let sysInfo = uni.getSystemInfoSync();
				let platform = sysInfo.platform;

				//软件版本号  sysInfo.version
				//客户端平台，值域为：ios、android、mac（3.1.10+）、windows（3.1.10+）、linux（3.1.10+）
				// //判断用户的手机类型
				if(this.closeProfit == 1 && platform == 'ios'){
					console.log("关闭IOS");
					return;
				}else if(this.closeProfit == 2 && platform == 'android'){
					console.log("关闭安卓");
					return;
				}else if(this.closeProfit == 3){
					console.log("关闭全部");
					return;
				}

				let obj = that.detailsObj;
				var params = {
					url: "/pbalance/save",
					method: "POST",
					data: {
						userId: obj.openid,
						souUserId: that.userId,
						source: 1,
						status: 1,
						dataType: 1,
						wid: obj.id
					},
					callBack: function(res) {
						//that.getIntegra();
					}
				};
				http.request(params); //加载评论
			},

			talentClick: function(e) {
				let userid = e.currentTarget.dataset.userid;
				userid = userid.replace(/\s+/g, ''); //全局替换空格

				if (userid == 0) {
					uni.navigateTo({
						url: '/pages/talent/talent?userid=' + userid
					});
				} else {
					uni.navigateTo({
						url: '/pages/talent/mytalent/mytalent?userid=' + userid
					});
				}
			},

			handlerComplaintClick: function() {},

			clickMask() {
				this.setData({
					modelShow: false
				});
			},

			/**
			 * 增加积分
			 */
			addIntegra: function(e) {
				let that = this;
				var params = {
					url: "/p/integral/addIntegra",
					method: "POST",
					data: {
						openid: that.userId,
						integral: 9,
						type: 0,
						explain: '看广告获取积分',
						name: '观看广告',
						consumptionIncome: 1
					},
					callBack: function(res) {
						if (res.code == 200) {
							that.getIntegra();
							uni.showToast({
								title: '获取成功',
								icon: 'success',
								duration: 2000
							});
						}
					}
				};
				http.request(params);
			},

			/**
			 * 增加积分
			 */
			seeShipin: function(e) {

				// if (Constants.ON_LINE_VERSION) {
				// 	this.readMore();
				// } else {
				// 	this.addIntegra();
				// }
			},

			/**
			 * 获取积分信息
			 */
			getIntegra: function() {
				let that = this;
				var params = {
					url: "/p/integral/getIntegra",
					method: "GET",
					data: {
						openid: that.userId
					},
					callBack: function(res) {
						if (res.code == 200) {
							that.setData({
								integra: res.data
							});
						}
					}
				};
				http.request(params);
			},

			/**
			 * 添加日志信息
			 */
			addLogo: function(resultError,modular) {
				let that = this;
				var params = {
					url: "/miniLogo/addLogo",
					method: "POST",
					data: {
						type:1,
						resultError:resultError,
						modular:modular,
						dataId:that.detailsObj.id
					},
					callBack: function(res) {

					}
				};
				http.request(params);
			},


		}
	};
</script>
<style>
	@import './article.css';
</style>
